package com.chixing.work_04;

public class CreditAccount extends Account{
    private float maxOverdraw;//最高透支额度
    private float alreadyOverdraw;//已透支的额度

    public CreditAccount(){}

    public CreditAccount(long accNo, String accName, String accPassword, long accTelno, float accBalance) {
        super(accNo, accName, accPassword, accTelno, accBalance);
    }

    public float withdraw(float balance){
        if (super.getAccBalance() < balance) {
            this.alreadyOverdraw = balance - super.getAccBalance();
            return super.withdraw(super.getAccBalance());
        }
        else
            return super.withdraw(balance);
    }

    public float getMaxOverdraw() {
        return maxOverdraw;
    }

    public void setMaxOverdraw(float maxOverdraw) {
        this.maxOverdraw = maxOverdraw;
    }

    public float getAlreadyOverdraw() {
        return alreadyOverdraw;
    }

    public void setAlreadyOverdraw(float alreadyOverdraw) {
        this.alreadyOverdraw = alreadyOverdraw;
    }
}
